package com.google.code.expr.lang;

import java.io.PrintWriter;
import java.io.StringWriter;


public class EXPRConditionalCase extends EXPRAtom {

	private EXPRConditonalType mType;
	private EXPRExpression mExpression;
	private EXPRBlock mBlock;
	
	public EXPRConditionalCase(EXPRConditonalType pType) {
		mType = pType;
	}
	
	
	public EXPRExpression getExpression() {
		return mExpression;
	}

	public void setExpression(EXPRExpression pExpression) {
		mExpression  = pExpression;
	}

	public void setBlock(EXPRBlock block) {
		mBlock = block;
	}
	
	public EXPRBlock getBlock() {
		return mBlock;
	}

	public EXPRConditonalType getType() { 
		return mType;
	}
	
	public String toString() {
		return toString("");
	}
	
	public String toString(String pIndent) {
		StringWriter writer = new StringWriter();
		PrintWriter out = new PrintWriter(writer);
		out.print(pIndent);
		out.print(COMMAND_START);
		out.print(mType);
		if (mType.isRequiresExpression()) {
			out.print(" ");
			out.print(mExpression);
		}
		out.print(COMMAND_END);
		if (mType.isRequiredBlock()) {
			out.println();
			out.print(mBlock.toString(pIndent+"  "));
		}
		return writer.toString();
	}

}
